//
//  PageCell.m
//  PageTool
//
//  Created by Burn on 2020/3/6.
//  Copyright © 2020 menksoft. All rights reserved.
//

#import "PageCell.h"

@interface PageCell ()

@property(strong,nonatomic) UILabel *indexLabel;

@end

@implementation PageCell



- (instancetype)initWithFrame:(CGRect)frame{
    if (self == [super initWithFrame:frame]) {
        self.indexLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, (self.bounds.size.height - self.bounds.size.width) * .5, self.bounds.size.width, self.bounds.size.width)];
        
        [self.contentView addSubview:self.indexLabel];
        self.indexLabel.layer.cornerRadius = self.bounds.size.width * .5;
        self.indexLabel.layer.masksToBounds = YES;
        self.indexLabel.textAlignment = NSTextAlignmentCenter;
        
        self.indexLabel.layer.borderWidth = .2;
        self.indexLabel.layer.borderColor = [UIColor lightGrayColor].CGColor;
    }
    return self;
}

- (void)setIndex:(NSInteger)index{
    _index = index;
    self.indexLabel.text = [NSString stringWithFormat:@"%ld",index + 1];
}


- (void)setPageSelected:(BOOL)pageSelected{
    _pageSelected = pageSelected;
    self.indexLabel.textColor = pageSelected ? [UIColor blueColor] : [UIColor blackColor];
    self.indexLabel.layer.borderColor = pageSelected ? [UIColor blueColor].CGColor : [UIColor lightGrayColor].CGColor;
    self.indexLabel.font = pageSelected ? [UIFont systemFontOfSize:20] : [UIFont systemFontOfSize:17];
}

@end

